﻿// JSON C# Class Generator
// http://at-my-window.blogspot.com/?page=json-class-generator

using System;
using Newtonsoft.Json.Linq;
using JsonCSharpClassGenerator;
using TomatoSynchronizer.Store;
using System.Collections.Generic;
using System.Collections.Specialized;

namespace TomatoSynchronizer.Entities
{

	public class Product : IComparable
	{
		private Category[] _categories;
		public Category[] Categories {
			get { return _categories; }
			set { _categories = value; }
		}
		
		private List<ProductAttribut> _attributs;
		public List<ProductAttribut> Attributs {
			get { return _attributs; }
			set { _attributs = value; }
		}

		private List<ProductImage> _images;
		public List<ProductImage> Images {
			get { return _images; }
			set { _images = value; }
		}
		
		private List<ProductVariant> variants_products;
		public List<ProductVariant> Variants_products {
			get { return variants_products; }
			set { variants_products = value; }
		}
		
		private List<XsellProduct> xsell_products;
		public List<XsellProduct> Xsell_products {
			get { return xsell_products; }
			set { xsell_products = value; }
		}
		
		private List<ProductAttachment> products_attachments;
		public List<ProductAttachment> Products_attachments {
			get { return products_attachments; }
			set { products_attachments = value; }
		}
		
		private List<ProductAccessory> accessories;
		public List<ProductAccessory> Accessories {
			get { return accessories; }
			set { accessories = value; }
		}
		
		private IStore<Product> store;		
		public IStore<Product> Store
		{
			get
			{
				return store;
			}
			set
			{
				store = value;
			}
		}
		
		public override int GetHashCode()
		{
			return base.GetHashCode();
		}
		
		public int CompareTo(object obj)
		{

			if (obj is Product)
			{

				Product p = (Product)obj;
				
				DateTime dateModifiedSrc = DateTime.Parse(_products_last_modified);
				DateTime dateModifiedDest = DateTime.Parse(p._products_last_modified);

				return dateModifiedSrc.CompareTo(dateModifiedDest);

			}
			else
				throw new ArgumentException("Object is not a Product");
		}
		
		public override bool Equals(object obj)
		{
			if(obj is Product)
			{
				Product product = (Product)obj;
				if(product._products_date_available == _products_date_available && product._products_description == _products_description && product._products_friendly_url == _products_friendly_url && product._products_keyword == _products_keyword && product._products_type == _products_type && product._products_meta_description == _products_meta_description && product._products_meta_keywords == _products_meta_keywords && product._products_model == _products_model && product._products_name == _products_name && product._products_page_title == _products_page_title && product._products_price == _products_price && product._products_short_description == _products_short_description && product._products_sku == _products_sku && product._products_status == _products_status && product._products_url == _products_url)
				{
					if(product.Images.Count == _images.Count)
					{
						foreach(ProductImage imageSrc in product.Images)
						{
							bool sync = false;
							
							foreach(ProductImage imageDest in product.Images)
							{
								if(imageSrc.Equals(imageDest))
								{
									sync = true;
								}
							}
							
							if(sync == false)
							{
								return false;
							}
						}
						
						if(product._attributs.Count == _attributs.Count)
						{
							foreach(ProductAttribut attributSrc in product.Attributs)
							{
								bool sync = false;
								
								foreach(ProductAttribut attributDest in _attributs)
								{
									if(attributSrc.Equals(attributDest))
									{
										sync = true;
									}
								}
								
								if(sync == false)
								{
									return false;
								}
							}
						}
						else
						{
							return false;
						}
						
						if(product._attributs.Count == _attributs.Count)
						{
							foreach(ProductAttribut attributSrc in product.Attributs)
							{
								bool sync = false;
								
								foreach(ProductAttribut attributDest in _attributs)
								{
									if(attributSrc.Equals(attributDest))
									{
										sync = true;
									}
								}
								
								if(sync == false)
								{
									return false;
								}
							}
						}
						else
						{
							return false;
						}
						
						if(product.accessories.Count == accessories.Count)
						{
							foreach(ProductAccessory accessorySrc in product.accessories)
							{
								bool sync = false;
								
								foreach(ProductAccessory accessoryDest in accessories)
								{
									if(accessorySrc.Equals(accessoryDest))
									{
										sync = true;
									}
								}
								
								if(sync == false)
								{
									return false;
								}
							}
						}
						else
						{
							return false;
						}
						
						if(product.products_attachments.Count == products_attachments.Count)
						{
							foreach(ProductAttachment fileSrc in product.products_attachments)
							{
								bool sync = false;
								
								foreach(ProductAttachment fileDest in products_attachments)
								{
									if(fileSrc.Equals(fileDest))
									{
										sync = true;
									}
								}
								
								if(sync == false)
								{
									return false;
								}
							}
						}
						else
						{
							return false;
						}
						
						if(product.variants_products.Count == variants_products.Count)
						{
							foreach(ProductVariant variantSrc in product.variants_products)
							{
								bool sync = false;
								
								foreach(ProductVariant variantDest in variants_products)
								{
									if(variantSrc.Equals(variantDest))
									{
										sync = true;
									}
								}
								
								if(sync == false)
								{
									return false;
								}
							}
						}
						else
						{
							return false;
						}
						
						if(product.xsell_products.Count == xsell_products.Count)
						{
							foreach(XsellProduct xsellSrc in product.xsell_products)
							{
								bool sync = false;
								
								foreach(XsellProduct xsellDest in xsell_products)
								{
									if(xsellSrc.Equals(xsellDest))
									{
										sync = true;
									}
								}
								
								if(sync == false)
								{
									return false;
								}
							}
						}
						else
						{
							return false;
						}
						
						return true;
					}
					
					return false;
				}
			}
			
			return false;
		}

		public Product()
		{
		}

		public Product(string json)
			: this(JObject.Parse(json))
		{
		}

		private JObject __jobject;
		public Product(JObject obj)
		{
			this.__jobject = obj;
		}

		[System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
		private string _products_id;
		public string products_id
		{
			get
			{
				if(_products_id == null)
					_products_id = JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "products_id"));
				return _products_id;
			}
			set
			{
				_products_id = value;
			}
		}

		[System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
		private string _products_type;
		public string products_type
		{
			get
			{
				if(_products_type == null)
					_products_type = JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "products_type"));
				return _products_type;
			}
			set
			{
				_products_type = value;
			}
		}

		[System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
		private string _products_quantity;
		public string products_quantity
		{
			get
			{
				if(_products_quantity == null)
					_products_quantity = JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "products_quantity"));
				return _products_quantity;
			}
			set
			{
				_products_quantity = value;
			}
		}

		[System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
		private string _products_moq;
		public string products_moq
		{
			get
			{
				if(_products_moq == null)
					_products_moq = JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "products_moq"));
				return _products_moq;
			}
			set
			{
				_products_moq = value;
			}
		}

		[System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
		private string _products_max_order_quantity;
		public string products_max_order_quantity
		{
			get
			{
				if(_products_max_order_quantity == null)
					_products_max_order_quantity = JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "products_max_order_quantity"));
				return _products_max_order_quantity;
			}
			set
			{
				_products_max_order_quantity = value;
			}
		}

		[System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
		private string _products_price;
		public string products_price
		{
			get
			{
				if(_products_price == null)
					_products_price = JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "products_price"));
				return _products_price;
			}
			set
			{
				_products_price = value;
			}
		}

		[System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
		private string _products_sku;
		public string products_sku
		{
			get
			{
				if(_products_sku == null)
					_products_sku = JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "products_sku"));
				return _products_sku;
			}
			set
			{
				_products_sku = value;
			}
		}

		[System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
		private string _products_model;
		public string products_model
		{
			get
			{
				if(_products_model == null)
					_products_model = JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "products_model"));
				return _products_model;
			}
			set
			{
				_products_model = value;
			}
		}

		[System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
		private string _products_date_added;
		public string products_date_added
		{
			get
			{
				if(_products_date_added == null)
					_products_date_added = JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "products_date_added"));
				return _products_date_added;
			}
			set
			{
				_products_date_added = value;
			}
		}

		[System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
		private string _products_last_modified;
		public string products_last_modified
		{
			get
			{
				if(_products_last_modified == null)
					_products_last_modified = JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JToken>(__jobject, "products_last_modified"));
				return _products_last_modified;
			}
			set
			{
				_products_last_modified = value;
			}
		}

		[System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
		private string _products_date_available;
		public string products_date_available
		{
			get
			{
				if(_products_date_available == null)
					_products_date_available = JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JToken>(__jobject, "products_date_available"));
				return _products_date_available;
			}
			set
			{
				_products_date_available = value;
			}
		}

		[System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
		private string _products_weight;
		public string products_weight
		{
			get
			{
				if(_products_weight == null)
					_products_weight = JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "products_weight"));
				return _products_weight;
			}
			set
			{
				_products_weight = value;
			}
		}

		[System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
		private string _products_weight_class;
		public string products_weight_class
		{
			get
			{
				if(_products_weight_class == null)
					_products_weight_class = JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "products_weight_class"));
				return _products_weight_class;
			}
			set
			{
				_products_weight_class = value;
			}
		}

		[System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
		private string _products_status;
		public string products_status
		{
			get
			{
				if(_products_status == null)
					_products_status = JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "products_status"));
				return _products_status;
			}
			set
			{
				_products_status = value;
			}
		}

		[System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
		private string _products_tax_class_id;
		public string products_tax_class_id
		{
			get
			{
				if(_products_tax_class_id == null)
					_products_tax_class_id = JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "products_tax_class_id"));
				return _products_tax_class_id;
			}
			set
			{
				_products_tax_class_id = value;
			}
		}

		[System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
		private string _manufacturers_id;
		public string manufacturers_id
		{
			get
			{
				if(_manufacturers_id == null)
					_manufacturers_id = JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "manufacturers_id"));
				return _manufacturers_id;
			}
			set
			{
				_manufacturers_id = value;
			}
		}

		[System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
		private string _products_ordered;
		public string products_ordered
		{
			get
			{
				if(_products_ordered == null)
					_products_ordered = JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "products_ordered"));
				return _products_ordered;
			}
			set
			{
				_products_ordered = value;
			}
		}

		[System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
		private string _quantity_discount_groups_id;
		public string quantity_discount_groups_id
		{
			get
			{
				if(_quantity_discount_groups_id == null)
					_quantity_discount_groups_id = JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "quantity_discount_groups_id"));
				return _quantity_discount_groups_id;
			}
			set
			{
				_quantity_discount_groups_id = value;
			}
		}

		[System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
		private string _quantity_unit_class;
		public string quantity_unit_class
		{
			get
			{
				if(_quantity_unit_class == null)
					_quantity_unit_class = JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "quantity_unit_class"));
				return _quantity_unit_class;
			}
			set
			{
				_quantity_unit_class = value;
			}
		}

		[System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
		private string _order_increment;
		public string order_increment
		{
			get
			{
				if(_order_increment == null)
					_order_increment = JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "order_increment"));
				return _order_increment;
			}
			set
			{
				_order_increment = value;
			}
		}

		[System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
		private object _products_attributes_groups_id;
		public object products_attributes_groups_id
		{
			get
			{
				if(_products_attributes_groups_id == null)
					_products_attributes_groups_id = JsonClassHelper.ReadObject(JsonClassHelper.GetJToken<JToken>(__jobject, "products_attributes_groups_id"));
				return _products_attributes_groups_id;
			}
			set
			{
				_products_attributes_groups_id = value;
			}
		}

		[System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
		private string _language_id;
		public string language_id
		{
			get
			{
				if(_language_id == null)
					_language_id = JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "language_id"));
				return _language_id;
			}
			set
			{
				_language_id = value;
			}
		}

		[System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
		private string _products_name;
		public string products_name
		{
			get
			{
				if(_products_name == null)
					_products_name = JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "products_name"));
				return _products_name;
			}
			set
			{
				_products_name = value;
			}
		}

		[System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
		private string _products_short_description;
		public string products_short_description
		{
			get
			{
				if(_products_short_description == null)
					_products_short_description = JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "products_short_description"));
				return _products_short_description;
			}
			set
			{
				_products_short_description = value;
			}
		}

		[System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
		private string _products_description;
		public string products_description
		{
			get
			{
				if(_products_description == null)
					_products_description = JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "products_description"));
				return _products_description;
			}
			set
			{
				_products_description = value;
			}
		}

		[System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
		private object _products_keyword;
		public object products_keyword
		{
			get
			{
				if(_products_keyword == null)
					_products_keyword = JsonClassHelper.ReadObject(JsonClassHelper.GetJToken<JToken>(__jobject, "products_keyword"));
				return _products_keyword;
			}
			set
			{
				_products_keyword = value;
			}
		}

		[System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
		private string _products_tags;
		public string products_tags
		{
			get
			{
				if(_products_tags == null)
					_products_tags = JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "products_tags"));
				return _products_tags;
			}
			set
			{
				_products_tags = value;
			}
		}

		[System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
		private string _products_url;
		public string products_url
		{
			get
			{
				if(_products_url == null)
					_products_url = JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "products_url"));
				return _products_url;
			}
			set
			{
				_products_url = value;
			}
		}

		[System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
		private string _products_friendly_url;
		public string products_friendly_url
		{
			get
			{
				if(_products_friendly_url == null)
					_products_friendly_url = JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "products_friendly_url"));
				return _products_friendly_url;
			}
			set
			{
				_products_friendly_url = value;
			}
		}

		[System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
		private string _products_page_title;
		public string products_page_title
		{
			get
			{
				if(_products_page_title == null)
					_products_page_title = JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "products_page_title"));
				return _products_page_title;
			}
			set
			{
				_products_page_title = value;
			}
		}

		[System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
		private string _products_meta_keywords;
		public string products_meta_keywords
		{
			get
			{
				if(_products_meta_keywords == null)
					_products_meta_keywords = JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "products_meta_keywords"));
				return _products_meta_keywords;
			}
			set
			{
				_products_meta_keywords = value;
			}
		}

		[System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
		private string _products_meta_description;
		public string products_meta_description
		{
			get
			{
				if(_products_meta_description == null)
					_products_meta_description = JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "products_meta_description"));
				return _products_meta_description;
			}
			set
			{
				_products_meta_description = value;
			}
		}

		[System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
		private string _products_viewed;
		public string products_viewed
		{
			get
			{
				if(_products_viewed == null)
					_products_viewed = JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "products_viewed"));
				return _products_viewed;
			}
			set
			{
				_products_viewed = value;
			}
		}

		[System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
		private string[] _categories_id;
		public string[] categories_id
		{
			get
			{
				if(_categories_id == null)
				{
					_categories_id = JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "categories_id")).Split(',');					
				}					
				return _categories_id;
			}
			set
			{
				_categories_id = value;
			}
		}
	}
}
